<%--
  Created by IntelliJ IDEA.
  User: lishunlin110
  Date: 2021/6/27
  Time: 11:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@page import="java.util.*" %>
<%@ page import="ProjectServlet.ConnectMySql" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.io.PrintWriter" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>管理员权限</title>
    <style>
        .condition{
            position: relative;
            display: inline-block;
            background-color: dimgrey;
            text-align: center;
            min-width: 160px;
            height: 40px;
        }
        .condition_content {
            display: none;
            position: absolute;
            background-color: #f9f9f9;
            min-width: 100px;
            box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
            padding: 12px 16px;
            z-index: 1;
        }
        .condition:hover .condition_content {
            display: block;
        }

        body {margin:0;}

        .navigator {
            list-style-type: none;
            margin: 0;
            padding: 0;
            background-color: #333;
            position: fixed;
            top: 0;
            width: 100%;
            height: 40px;
        }

        li {
            float: left;
            height: 40px;
            border-right: 1px solid #bbb;
        }
        li:last-child{
            border-right: none;
        }

        .house{
            border:10px;
            width:80%;
            text-align:center;

        }
        tr{
            border: 5px;
            text-align: center;
        }

        table {
            border: 1px aquamarine solid;
            width: 500px;
            margin: auto;
        }

        td {
            border: 1px chartreuse solid;
            margin: 10px;
            padding: 10px;
            text-align: center;
        }

        th {
            background-color: aquamarine;
        }

    </style>

</head>
<body>
<form>
    <ul class="navigator">
        <li>
            <div id="space" class="condition" >操作小区信息
                <div id="space_content" class="condition_content">
                    <input type="button" onclick="onClick(1)" name="alter" value="增添小区信息" style="width:150px; text-align: center"><br/>
                    <input type="button" onclick="onClick(2)" name="alter" value="删除小区信息" style="width:150px; text-align: center"><br/>
                    <input type="button" onclick="onClick(3)" name="alter"  value="修改小区信息" style="width:150px; text-align: center"><br/>
                </div>
            </div>
        </li>
        <li>
            <div id="map" class="condition" >操作房源信息
                <div id="map_content" class="condition_content">
                    <input type="button" onclick="onClick(4)" name="alter" value="增添房源信息" style="width:150px; text-align: center"><br/>
                    <input type="button" onclick="onClick(5)" name="alter"  value="删除房源信息" style="width:150px; text-align: center"><br/>
                    <input type="button" onclick="onClick(6)" name="alter"  value="修改房源信息" style="width:150px; text-align: center"><br/>
                </div>
            </div>
        </li>
        <li>
            <div id="user" class="condition" >操作用户信息
                <div id="user_content" class="condition_content">
                    <input type="button" onclick="onClick(7)" name="alter" value="增加用户" style="width:150px; text-align: center"><br/>
                    <input type="button" onclick="onClick(8)" name="alter"  value="删除用户" style="width:150px; text-align: center"><br/>
                </div>
            </div>
        </li>
    </ul>
</form>
<script>
    function onClick(obj) {
        <% String level = (String) request.getAttribute("level");%>
        var L = "<%=level%>"
        if((obj===7||obj===8)&&L==="normalUser"){
            alert("你的权限太低!");
            return;
        }
        for(var i = 1;i<=8;i++){
            if(i == obj){
                document.getElementById(i).style.display="block"
            }else
                document.getElementById(i).style.display="none"
        }
    }
</script>

<form action="http://localhost:8081/web2_war_exploded/servletForLog" method="get" id="1" style="display: none">--%>
                <input type="hidden" name="action" value="addCommunity">
                <table align="center" id="t1">
                    <h1 align="center ">增添小区信息</h1>
                    <tr>
                        <td>小区名称:</td>
                        <td><input type="text" name="name" ></td>
                    </tr>
                    <tr>
                        <td>经度:</td>
                        <td><input type="text" name="longitude" ></td>
                    </tr>
                    <tr>
                        <td>纬度:</td>
                        <td><input type="text" name="latitude" ></td>
                    </tr>
                    <tr>
                        <td>所在行政区:</td>
                        <td><input type="text" name="adm" ></td>
                    </tr>
                    <tr>
                        <td>销售状态:</td>
                        <td><input type="text" name="saleState" ></td>
                    </tr>
                    <tr>
                        <td>小区类型:</td>
                        <td><input type="text" name="type" ></td>
                    </tr>
                    <tr>
                        <td>价格:</td>
                        <td><input type="text" name="price" ></td>
                    </tr>
                    <tr>
                        <td>容积率:</td>
                        <td><input type="text" name="col" ></td>

                    </tr>
                    <tr>
                        <td>绿化率:</td>
                        <td><input type="text" name="greening" ></td>
                    </tr>
                    <tr>
                        <td><input type="submit" style="width:150px; text-align: center" ></td>
                    </tr>
                </table>
            </form>

<form action="http://localhost:8081/web2_war_exploded/servletForLog" method="get" id="2" style="display: none">
    <input type="hidden" name="action" value="deleteCommunity">
    <table align="center" id="t2">--%>
                <h1 align="center">删除小区信息</h1>
        <tr>
            <td>要删除的小区id:</td>
            <td><input type="text" name="deleteId" ></td>
        </tr>
        <tr>
            <td><input type="submit" style="width:150px; text-align: center" ></td>
        </tr>
            </table>
</form>

<form action="http://localhost:8081/web2_war_exploded/servletForLog" method="get" id="3" style="display: none">
    <input type="hidden" name="action" value="alterCommunity">
    <table align="center" id="t3">
        <h1 align="center">修改小区信息</h1>
        <tr>
            <td>要修改的小区id:</td>
            <td><input type="text" name="alterId" ></td>
        </tr>
        <tr>
            <td><input type="submit" style="width:150px; text-align: center" ></td>
        </tr>
    </table>
</form>


<form action="http://localhost:8081/web2_war_exploded/servletForLog" method="get" id="4" style="display: none">--%>
    <input type="hidden" name="action" value="addHouse">
    <table align="center" id="t4">
        <h1 align="center ">增添房源信息信息</h1>
        <tr>
            <td>户型:</td>
            <td><input type="text" name="houseType" ></td>
        </tr>
        <tr>
            <td>总价:</td>
            <td><input type="text" name="totalPrice" ></td>
        </tr>
        <tr>
            <td>均价:</td>
            <td><input type="text" name="averagePrice" ></td>
        </tr>
        <tr>
            <td>总面积:</td>
            <td><input type="text" name="allArea" ></td>
        </tr>
        <tr>
            <td>室内面积:</td>
            <td><input type="text" name="insideArea" ></td>
        </tr>
        <tr>
            <td>朝向:</td>
            <td><input type="text" name="forward" ></td>
        </tr>
        <tr>
            <td>所在小区:</td>
            <td><input type="text" name="community" ></td>
        </tr>
        <tr>
            <td>所在楼层:</td>
            <td><input type="text" name="Hfloor" ></td>

        </tr>
        <tr>
            <td>总楼层:</td>
            <td><input type="text" name="totalFloor" ></td>
        </tr>
        <tr>
            <td>建筑年份:</td>
            <td><input type="text" name="years" ></td>
        </tr>
        <tr>
            <td>建筑类型:</td>
            <td><input type="text" name="types" ></td>
        </tr>
        <tr>
            <td><input type="submit" style="width:150px; text-align: center" ></td>
        </tr>
    </table>
</form>

<form action="http://localhost:8081/web2_war_exploded/servletForLog" method="get" id="5" style="display: none">
    <input type="hidden" name="action" value="deleteHouse">
    <table align="center" id="t5">--%>
        <h1 align="center">删除房源信息</h1>
        <tr>
            <td>要删除的房源id:</td>
            <td><input type="text" name="deleteId" ></td>
        </tr>
        <tr>
            <td><input type="submit" style="width:150px; text-align: center" ></td>
        </tr>
    </table>
</form>

<form action="http://localhost:8081/web2_war_exploded/servletForLog" method="get" id="6" style="display: none">
    <input type="hidden" name="action" value="alterHouse">
    <table align="center" id="t6">
        <h1 align="center">修改房源信息</h1>
        <tr>
            <td>要修改的小区id:</td>
            <td><input type="text" name="alterId" ></td>
        </tr>
        <tr>
            <td><input type="submit" style="width:150px; text-align: center" ></td>
        </tr>
    </table>
</form>


<form action="http://localhost:8081/web2_war_exploded/servletForLog" method="get" id="7" style="display: none">
    <input type="hidden" name="action" value="addUser">
    <table align="center" id="t7">
        <h1 align="center">添加用户</h1>
        <tr>
            <td>企业用户:</td>
            <td><input type="radio" name="userLevel" value="normalUser"/></td>
        </tr>
        <tr>
            <td>游客:</td>
            <td><input type="radio" name="userLevel" checked="checked"  value="visitor"/></td>
        </tr>
        <tr>
            <td>用户名:</td>
            <td><input type="text" name="userName"></td>
        </tr>
        <tr>
            <td>密码:</td>
            <td><input type="password" name="passWord"></td>
        </tr>
        <tr>
            <td><input type="submit" style="width:150px; text-align: center" ></td>
        </tr>
    </table>
</form>

<form action="http://localhost:8081/web2_war_exploded/servletForLog" method="get" id="8" style="display: none">
    <input type="hidden" name="action" value="deleteUser">
    <table align="center" >
        <h1 align="center">删除用户</h1>
        <tr>
            <td>输入要删除的用户名:</td>
            <td><input type="text" name="userName"></td>
        </tr>
        <tr>
            <td><input type="submit" style="width:150px; text-align: center" ></td>
        </tr>
    </table>
</form>
<%--显示信息--%>
<%
       String message =  (String) request.getAttribute("message");
        if(message!=null && !"".equals(message)){

      %>
     <script type="text/javascript">
              alert("<%=message%>");
         </script>
<%} %>

<%--显示小区信息--%>
<%
    ResultSet rs = (ResultSet)request.getAttribute("communityRsForDelete");
    if(rs!=null){
%>
    <script>
        document.getElementById("2").style.display="block"
    </script>
<form action="http://localhost:8081/web2_war_exploded/servletForLog" id="f2" method="get" >
    <input type="hidden" name="action" value="deleteConfirm">

<table align="center" id="table1">
            <tr>
            <th>名称</th>
            <th>所在行政区</th>
            <th>经度</th>
            <th>纬度</th>
            <th>销售状态</th>
            <th>类型</th>
            <th>价格</th>
            <th>容积率</th>
            <th>绿化率</th>
            </tr>
<%
        try {

            while (rs.next()){
 %>
    <tr>
                <td><%=rs.getString("name")%></td>
                <td><%=rs.getString("adm_region")%></td>
                <td><%=rs.getString("longitude")%></td>
                <td><%=rs.getString("latitude")%></td>
                <td><%=rs.getString("sale_state")%></td>
                <td><%=rs.getString("type")%></td>
                <td><%=rs.getString("price")%></td>
                <td><%=rs.getString("volume_fraction")%></td>
                <td><%=rs.getString("greening_rate")%></td>
    </tr>
    <tr>
        <td><input type="hidden" name="deleteSubmit" value="<%=rs.getString("id")%>"></td>
        <td><input type="submit" value="确认删除"></td>
    </tr>
<%
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

%>
</table>
</form>


<%
    ResultSet rs2 = (ResultSet)request.getAttribute("communityRsForAlter");
    if(rs2!=null){
%>
<script>
    document.getElementById("3").style.display="block"
</script>
<form action="http://localhost:8081/web2_war_exploded/servletForLog" id="f3" method="get" >
    <input type="hidden" name="action" value="alterConfirm">

    <table align="center" id="table3">
        <tr>
            <th>新旧值</th>
            <th>名称</th>
            <th>所在行政区</th>
            <th>经度</th>
            <th>纬度</th>
            <th>销售状态</th>
            <th>类型</th>
            <th>价格</th>
            <th>容积率</th>
            <th>绿化率</th>
        </tr>
        <%
            try {

                while (rs2.next()){
        %>
        <tr>
            <td>原值:</td>
            <td><%=rs2.getString("name")%></td>
            <td><%=rs2.getString("adm_region")%></td>
            <td><%=rs2.getString("longitude")%></td>
            <td><%=rs2.getString("latitude")%></td>
            <td><%=rs2.getString("sale_state")%></td>
            <td><%=rs2.getString("type")%></td>
            <td><%=rs2.getString("price")%></td>
            <td><%=rs2.getString("volume_fraction")%></td>
            <td><%=rs2.getString("greening_rate")%></td>
        </tr>
        <tr>
            <td>新值:</td>
            <td><input type="text" name="nameNew"></td>
            <td><input type="text" name="admNew"></td>
            <td><input type="text" name="longitudeNew"></td>
            <td><input type="text" name="latitudeNew"></td>
            <td><input type="text" name="saleStateNew"></td>
            <td><input type="text" name="typeNew"></td>
            <td><input type="text" name="priceNew"></td>
            <td><input type="text" name="colNew"></td>
            <td><input type="text" name="greenNew"></td>
        </tr>
        <tr>
            <td><input type="hidden" name="alterSubmit" value="<%=rs2.getString("id")%>"></td>
            <input type="submit" value="确认修改" style="width:150px; text-align: center" >
        </tr>
        <%
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }
            }

        %>
    </table>
</form>


<%--显示房源信息--%>
<%
    ResultSet rs3 = (ResultSet)request.getAttribute("HouseRsForDelete");
    if(rs3!=null){
%>
<script>
    document.getElementById("5").style.display="block"
</script>
<form action="http://localhost:8081/web2_war_exploded/servletForLog" id="f5" method="get" >
    <input type="hidden" name="action" value="deleteHouseConfirm">

    <table align="center">
        <tr>
            <th>id</th>
            <th>户型</th>
            <th>总价</th>
            <th>均价</th>
            <th>总面积</th>
            <th>室内面积</th>
            <th>朝向</th>
            <th>所在小区</th>
            <th>所在楼层</th>
            <th>总楼层</th>
            <th>建筑年份</th>
            <th>建筑类型</th>
        </tr>
        <%
            try {

                while (rs3.next()){
                    String id = rs3.getString("id");
        %>
        <tr>
            <td><%=id%></td>
            <td><%=rs3.getString("houseType")%></td>
            <td><%=rs3.getString("totalPrice")%></td>
            <td><%=rs3.getString("averagePrice")%></td>
            <td><%=rs3.getString("allArea")%></td>
            <td><%=rs3.getString("insideArea")%></td>
            <td><%=rs3.getString("forward")%></td>
            <td><%=rs3.getString("community")%></td>
            <td><%=rs3.getString("Hfloor")%></td>
            <td><%=rs3.getString("totalFloor")%></td>
            <td><%=rs3.getString("years")%></td>
            <td><%=rs3.getString("types")%></td>
        </tr>
        <tr>
            <td><input type="hidden" name="deleteHouseSubmit" value="<%=id%>"></td>
            <td><input type="submit" value="确认删除"></td>
        </tr>
        <%
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }
            }

        %>
    </table>
</form>


<%
    ResultSet rs4 = (ResultSet)request.getAttribute("HouseRsForAlter");
    if(rs4!=null){
%>
<script>
    document.getElementById("6").style.display="block"
</script>
<form action="http://localhost:8081/web2_war_exploded/servletForLog" id="f6" method="get" >
    <input type="hidden" name="action" value="alterHouseConfirm">

    <table align="center">
        <tr>
            <th>新旧值</th>
            <th>户型</th>
            <th>总价</th>
            <th>均价</th>
            <th>总面积</th>
            <th>室内面积</th>
            <th>朝向</th>
            <th>所在小区</th>
            <th>所在楼层</th>
            <th>总楼层</th>
            <th>建筑年份</th>
            <th>建筑类型</th>
        </tr>
        <%
            try {

                while (rs4.next()){
                    String id = rs4.getString("id");
        %>
        <tr>
            <td>原值:</td>
            <td><%=rs4.getString("houseType")%></td>
            <td><%=rs4.getString("totalPrice")%></td>
            <td><%=rs4.getString("averagePrice")%></td>
            <td><%=rs4.getString("allArea")%></td>
            <td><%=rs4.getString("insideArea")%></td>
            <td><%=rs4.getString("forward")%></td>
            <td><%=rs4.getString("community")%></td>
            <td><%=rs4.getString("Hfloor")%></td>
            <td><%=rs4.getString("totalFloor")%></td>
            <td><%=rs4.getString("years")%></td>
            <td><%=rs4.getString("types")%></td>
        </tr>
        <tr>
            <td>新值:</td>
            <td><input type="text" name="houseTypeNew"></td>
            <td><input type="text" name="totalPriceNew"></td>
            <td><input type="text" name="averagePriceNew"></td>
            <td><input type="text" name="allAreaNew"></td>
            <td><input type="text" name="insideAreaNew"></td>
            <td><input type="text" name="forwardNew"></td>
            <td><input type="text" name="communityNew"></td>
            <td><input type="text" name="HfloorNew"></td>
            <td><input type="text" name="totalFloorNew"></td>
            <td><input type="text" name="yearsNew"></td>
            <td><input type="text" name="typesNew"></td>
        </tr>
        <tr>
            <td><input type="hidden" name="alterSubmitHouse" value="<%=id%>"></td>
            <td><input type="submit" value="确认修改"></td>
        </tr>
        <%
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }
            }

        %>
    </table>
</form>















</body>
</html>

